/* This program produces the parts of Table B.3 that use administrative data 
- The table has to be assembled manually */

***** Set directories 
local dir_raw 		"~/Dropbox/Retirement gaming/raw"
local dir_clean 	"~/Dropbox/Retirement gaming/clean"
local dir_output 	"~/Dropbox/Retirement gaming/output/dataverse"

use "`dir_clean'/mainsample_age50analysis.dta", clear


*SELF-EMPLOYED
estimates clear
	*Less than 50
	eststo: quietly estpost summarize W if self_empl==1  & age_centered<0, casewise esample
	eststo: quietly estpost summarize W if self_empl==1  & age_centered>=0 & age_centered<4, casewise esample
	eststo: quietly estpost summarize W if self_empl==1  & age_centered>=4 & age_centered<., casewise esample
	esttab using "`dir_output'/tableB3_admin.tex", replace ///
		cells("mean(fmt(2))")  nostar nonote label nonumber nodepvar ///
		mtitles("Age 45-49" "Age 50-53" "Age 54-57") ///
		style(tex) f nogaps noobs
*SMALL-FIRM EMPLOYEES
estimates clear
	*Less than 50
	eststo: quietly estpost summarize W if empl==1 & prop_mempl>=0 & large_1stobs==0 & age_centered<0, casewise esample
	eststo: quietly estpost summarize W if empl==1 & prop_mempl>=0 & large_1stobs==0 & age_centered>=0 & age_centered<4, casewise esample
	eststo: quietly estpost summarize W if empl==1 & prop_mempl>=0 & large_1stobs==0 & age_centered>=4 & age_centered<., casewise esample
	esttab using "`dir_output'/tableB3_admin.tex", append ///
		cells("mean(fmt(2))")  nostar nonote label nonumber nodepvar ///
		nomtitles ///
		style(tex) f nogaps noobs
*LARGE-FIRM EMPLOYEES
estimates clear
	*Less than 50
	eststo: quietly estpost summarize W if empl==1 & prop_mempl>=0 & large_1stobs==1 & age_centered<0, casewise esample
	eststo: quietly estpost summarize W if empl==1 & prop_mempl>=0 & large_1stobs==1 & age_centered>=0 & age_centered<4, casewise esample
	eststo: quietly estpost summarize W if empl==1 & prop_mempl>=0 & large_1stobs==1 & age_centered>=4 & age_centered<., casewise esample
	esttab using "`dir_output'/tableB3_admin.tex", append ///
		cells("mean(fmt(2))")  nostar nonote label nonumber nodepvar ///
		nomtitles ///
		style(tex) f nogaps noobs

		
		
		
exit
		
		
		
		
